home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!dfdesign.demon.co.uk
- From: Dominic Feeley <dom@dfdesign.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: Beginer C please help me
- Date: Sat, 23 Mar 96 19:06:36 GMT
- Organization: DF Designs
- Message-ID: <827607996snz@dfdesign.demon.co.uk>
- References: <DoLCFx.B7x.0.bloor@torfree.net> <4iqd15$ajd@loki.tor.hookup.net>
- Reply-To: dom@dfdesign.demon.co.uk
- X-NNTP-Posting-Host: dfdesign.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.30
- X-Mail2News-Path: dfdesign.demon.co.uk
-
- In article <4iqd15$ajd@loki.tor.hookup.net>
- Rajendra_Singh@msn.com "Rajendra Singh" writes:
- > bz786@torfree.net (Sherif Asif) wrote:
- > > float n;
- > > n = ( 9 / 5 ) ;
- > > printf( "n= %1.3f\n", n ) ;
- > > I have complied and run the programme & I got the answer n=1.000
- > > but Iam supposed to get answer 1.8.
- > You are dividing an integer by an integer, hence the result is an
- > integer. Change one or both of the operands to a float, i. e. change
- > 9 to 9. and/or 5 to 5., and you will get the desired result.
-
- It makes life much easier to make this 9.0 or 5.0 as it's more
- obvious you are using floating point numbers.
-
- Regards,
- Dominic.
-
- --
- Dominic Feeley
-